import React, { PureComponent } from 'react';
import { Form, Row, Col, Cascader, DatePicker, Input, Select, Radio } from 'antd';
import moment from 'moment';
import { DEFAULT_RESPONE_SUCCESS, DEFAULT_VALID_STATE } from '@/constants';
import List from '@/pages/Emergency';

const { TextArea } = Input;
const { Option } = Select;
const { RangePicker } = DatePicker;

export default class Index extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      selectedEvents: [],
      timeType: "早"
    }
  }

  componentDidMount() {
  }

  onChangeQKMS = e => {
    this.setState({
      timeType: e.target.value,
    }, () => {
      const { form } = this.props;
      const { timeType } = this.state;
      if (timeType == "早") {
        form.setFieldsValue({ qishu: [moment().startOf('day'), moment().startOf('day').add(9, "hours")] });
      } else if (timeType == "晚") {
        form.setFieldsValue({ qishu: [moment().startOf('day').add(9, "hours"), moment().startOf('day').add(18, "hours")] });
      }
    });
  };


  render() {
    const { selectedEvents = [] } = this.state;
    const { form, data = {}, disabled = false, dispatch, modularName } = this.props;
    const { getFieldDecorator } = form;

    return (
      <div>
        <Form layout='vertical'>
          <Row gutter={16} type='flex'>
            <Col span={16}>
              <div style={{ marginBottom: 16 }}>
                <Form.Item label='时间'>
                  {getFieldDecorator('qishu', {
                    initialValue: [moment().startOf('day'), moment().startOf('day').add(9, "hours")],
                    rules: [{ required: true, message: '该项为必填项' }]
                  })(
                    <RangePicker
                      showTime={{ format: 'HH:mm' }}
                      format="YYYY-MM-DD HH:mm"
                    />
                  )}
                </Form.Item>
              </div>
            </Col>
            <Col span={8}>
              <div style={{ marginBottom: 16 }}>
                <Form.Item label='时间段'>
                  {getFieldDecorator('timeType', {
                    initialValue: this.state.timeType,
                    rules: [{ required: true, message: '该项为必填项' }]
                  })(
                    <Radio.Group onChange={this.onChangeQKMS} value={this.state.timeType} style={{ marginTop: 6 }}>
                      <Radio value={"早"}>早8点</Radio>
                      <Radio value={"晚"}>晚8点</Radio>
                    </Radio.Group>
                  )}
                </Form.Item>
              </div>
            </Col>
          </Row>
        </Form>
        {/* <List
          mode='select'
          style={{ backgroundColor: '#fff' }}
          rowSelection={{
            onChange: (selectedRowKeys, rows) => {
              dispatch({
                type: `${modularName}/changeState`,
                payload: {
                  selectedEvents: [...selectedEvents.filter(item => selectedRowKeys.includes(item.id) && !rows.map(row => row.id).includes(item.id)), ...rows]
                }
              });
            }
          }}
        /> */}
      </div>
    );
  }
}
